package com.taritari.journal.controller;

import com.taritari.journal.entity.po.WordCloud;
import com.taritari.journal.entity.vo.SentimentClassify;
import com.taritari.journal.services.SentimentClassifyService;
import com.taritari.journal.utils.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @author taritari
 * @date 2024-01-11 20:27
 * @description
 */
@RestController
@Slf4j
@Tag(name = "情感趋势", description = "情感趋势")
@RequestMapping("/sentiment")
public class SentimentClassifyController {
    @Autowired
    private SentimentClassifyService sentimentClassifyService;

    @GetMapping("/getSentimentById")
    @Operation(summary = "查询对应用户的日记情感趋势", description = "查询对应用户的日记情感趋势")
    public Result getSentimentById(@RequestParam int authorId) {
        List<SentimentClassify> sentimentClassifyById = sentimentClassifyService.getSentimentClassifyById(authorId);
        return Result.success(sentimentClassifyById);
    }


    @GetMapping("/getCountById")
    @Operation(summary = "获取对应用户的情感趋势统计结果", description = "获取对应用户的情感趋势统计结果")
    public Result getCountById(@RequestParam int authorId) {
        Map<String, List<Object>> sentimentCountById = sentimentClassifyService.getSentimentCountById(authorId);
        return Result.success(sentimentCountById);
    }
    @GetMapping("/getByNumber")
    @Operation(summary = "通过journalNumber查询情感趋势详情", description = "通过journalNumber查询情感趋势详情")
    public Result getByNumber(@RequestParam String number){
        SentimentClassify sentimentClassify = sentimentClassifyService.selectOneByJournalNumber(number);
        return Result.success(sentimentClassify);
    }
    @GetMapping("/getWordCloud")
    @Operation(summary = "通过作者id获得词云", description = "通过作者id获得词云")
    public Result getWordCloud(@RequestParam int authorId){
        Map<String, List<WordCloud>> stringListMap = sentimentClassifyService.selectJournalNumberByAuthorId(authorId);
        return Result.success(stringListMap);
    }

}
